home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / ucrasm27.zip / SOURCE.ZIP / CRLIST.ASM < prev    next >
Assembly Source File  |  1992-03-09  |  2KB  |  74 lines

  1. ; Need to include "lists.a" in order to get list structure definition.
  2.  
  3.         include    lists.a
  4.         extrn    sl_malloc:far
  5.  
  6.  
  7. StdGrp        group    stdlib,stddata
  8. stddata        segment    para public 'sldata'
  9. stddata        ends
  10.  
  11. stdlib        segment    para public 'slcode'
  12.         assume    cs:stdgrp
  13.  
  14. ; sl_CreateList-    Allocates storage for a new list variable on the
  15. ;            heap.  Initializes appropriate fields.
  16. ;
  17. ; Randall Hyde  3/2/92
  18. ;
  19. ; On Entry:
  20. ;
  21. ;        CX contains the number of bytes of data for each node
  22. ;        in the list (does not include the size of the links, etc.)
  23. ;
  24. ; On Exit:    ES:DI points at list variable on the head.
  25. ;        Carry is set if malloc error.
  26.  
  27.         public    sl_CreateList
  28. sl_CreateList    proc    far
  29.         push    cx
  30.         mov    cx, size List
  31.         call    sl_malloc
  32.         pop    cx
  33.         jc    BadCreateList
  34.  
  35. ; The following code varies depending upon whether this is MASM 6.0 or
  36. ; some other assembler:
  37.  
  38.         ifndef    @version
  39.         mov    es:[di].ListSize, cx    ;Not MASM 5.1 or MASM 6.0
  40.         mov    word ptr es:[di].Head, 0
  41.         mov    word ptr es:[di+2].Head, 0
  42.         mov    word ptr es:[di].Tail, 0
  43.         mov    word ptr es:[di+2].Tail, 0
  44.         mov    word ptr es:[di].CurrentNode, 0
  45.         mov    word ptr es:[di+2].CurrentNode, 0
  46.  
  47.         else
  48.         if    @version ge 600
  49.         mov    es:[di].list.ListSize, cx    ;MASM 6.0 or later
  50.         mov    word ptr es:[di].list.Head, 0
  51.         mov    word ptr es:[di+2].list.Head, 0
  52.         mov    word ptr es:[di].list.Tail, 0
  53.         mov    word ptr es:[di+2].list.Tail, 0
  54.         mov    word ptr es:[di].List.CurrentNode, 0
  55.         mov    word ptr es:[di+2].List.CurrentNode, 0
  56.  
  57.         else
  58.         mov    es:[di].ListSize, cx        ;Probably MASM 5.1
  59.         mov    word ptr es:[di].Head, 0
  60.         mov    word ptr es:[di+2].Head, 0
  61.         mov    word ptr es:[di].Tail, 0
  62.         mov    word ptr es:[di+2].Tail, 0
  63.         mov    word ptr es:[di].CurrentNode, 0
  64.         mov    word ptr es:[di+2].CurrentNode, 0
  65.         endif
  66.         endif
  67.         clc                ;Not really needed, C=0 already
  68. BadCreateList:    ret
  69.  
  70. sl_CreateList    endp
  71.  
  72. stdlib        ends
  73.         end
  74.